AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include('shared.lua')
local Ground = 1 + 0 + 2 + 8 + 32

function ENT:Initialize()
	self.active = true
	self.Entity:SetModel( "models/props_c17/canister01a.mdl" )
	self.Entity:PhysicsInit( SOLID_VPHYSICS )
	self.Entity:SetMoveType(  MOVETYPE_VPHYSICS   )
	self.Entity:SetSolid( SOLID_VPHYSICS )
	self.Entity:SetName("Fighter.Ship.Steering.Unit")
	local phys = self.Entity:GetPhysicsObject()
	if (phys:IsValid()) then
		phys:Wake()
	end
	self.Angles = self.Entity:GetAngles()
	self.Physik = phys
	self.Pos = self.Entity:GetPos()
	self.maxpower = 350
	self.power = 0
	phys:SetMass( 30000 )
	self.Entity:StartMotionController()
	table.insert(servertable["ship"]["controller"],self.Entity)
	
end

function ENT:SpawnFunction( ply, tr )
	if ( !tr.Hit ) then return end
	local SpawnPos = tr.HitPos + tr.HitNormal * 36
	local ent = ents.Create( "Test" )
	ent:SetPos( SpawnPos )
	ent:Spawn()
	ent:Activate()
	return ent
end

function ENT:PhysicsSimulate() 
 	self.Physik:Wake()
	self.ShadowParams={} 
	self.ShadowParams.secondstoarrive	= 1
	self.ShadowParams.pos			= self.Pos
	self.ShadowParams.angle			= self.Angles
	self.ShadowParams.maxangular		= 50
	self.ShadowParams.maxangulardamp	= 30
	self.ShadowParams.maxspeed		= 500
	self.ShadowParams.maxspeeddamp		= 1500
	self.ShadowParams.dampfactor		= 0.4
	self.ShadowParams.teleportdistance	= 0
	self.ShadowParams.deltatime		= 1
	self.Physik:ComputeShadowControl(self.ShadowParams) 
end  
 
function ENT:OnTakeDamage(info)
	Shieldhit(info,self.Entity)
end
